﻿@{
    Layout = null;
    int z = 0;
}
@model EnterpriseFund.Model.AllowanceIssue
<!DOCTYPE html>
@Html.Partial("LoadPanelPartial")
<html>
<head>
    <title></title> 
       @if (false)
       {
        <script src="../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
       }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <link href="@Url.Content("~/Content/jquery-ui.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery-ui.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/regex.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

        new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
)
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
)
<script>
    $(document).ready(function () {
        $("#toolMenu").smartFloat();
        var hdjsAlert = $("#hdjsAlert").val();
        if (hdjsAlert != "") {
            alert(hdjsAlert);
        }
        if (hdjsAlert == "操作成功") {
            var hidSType = $("#hidSType").val();
            if (hidSType == "ALL") {
                window.location.href = rootPath + '/AllowanceIssueCheck/';
            }
            else {
                window.location.href = rootPath + '/AllowanceIssueCheck/AllowanceIssueCheckEdit?FIssueID=' + $("#hidFIssueID").val();
            }
        }
    });


    function MenuTop_emClick(source, e) {
        switch (e.item.name) {
            case "btnSubmitALL":
                {
                    if (confirm("是否确定发送选中数据？")) {
                        var value = "";
                        var boc = document.getElementsByName("box");
                        for (var i = 0; i < boc.length; i++) {
                            if (boc[i].checked) {
                                if (value == "") {
                                    value += "'" + boc[i].value + "'";
                                }
                                else {
                                    value += ",'" + boc[i].value + "'";
                                }
                            }
                        }
                        $("#hidcheckNoALL").val(value);
                        $("#hidSType").val("Portion");
                        Save();
                    }
                    break;
                }
//            case "btnSubmit":
//                {
//                    if (confirm("是否确定发送全部数据？")) {
//                        $("#hidSType").val("ALL");
//                        Save();
//                    }
//                    break;
//                }
            case "btnReturn":
                {
                    $.ajax({
                        type: 'POST',
                        url: rootPath + '/AllowanceIssueCheck/IsReturn',
                        data: { FIssueID: $("#hidFIssueID").val() },
                        success: function (result) {
                            if (result == "ok") {
                                var rs = window.showModalDialog(rootPath + "/ReturnDlg?tableName=t_AllowanceIssue&id=" + $("#hidFIssueID").val() + "&feq=20");

                                if (rs == "S") {
                                    window.location.href = rootPath + '/AllowanceIssueCheck/';
                                }
                            }
                            else {
                                alert("该期号已存在资金汇总表无法退回");
                            }
                        }
                    });
                    break;
                }
            case "btnback":
                {
                    window.location.href = rootPath + '/AllowanceIssueCheck/';
                    break;
                }
        }

    }

    function look(no, id) {
        window.showModelessDialog(rootPath + "/AllowanceIssueCheck/LookEntry?taxClassAllowanceNo=" + no + "&FTaxAuditId=" + id, "", "dialogWidth=500px;dialogHeight=500px");
    }

    function Save() {
        form1.submit();
    }

    function Opents(allowanceIssueEntryID, id) {
        var type = $("#hidtype").val();
        $.ajax({
            type: 'POST',
            url: rootPath + '/AllowanceIssueCheck/OpenToIssue',
            data: { fallowanceIssueEntryID: allowanceIssueEntryID, FIssueID: $("#hidFIssueID").val(), type: type, EditType: "ts" },
            success: function (result) {
                var sdata = result.split("||");
                if (sdata[0] == "ok") {
                    if (type == "1") {
                        $("tr[id='" + id + "']").remove();
                    }
                    else {
                        $('#' + allowanceIssueEntryID + 'open').hide();
                    }
                    $("#zjse").text(sdata[1]);
                    $("#zjFAllowanceAmount").text(sdata[2]);
                    $("#zjYBTJE").text(sdata[3]);
                    $("#zjBTJE").text(sdata[4]);
                }
                else {
                    alert("系统异常");
                }
            }
        });
    }

    function Returnts(allowanceIssueEntryID, id) {
        var type = $("#hidtype").val();
        if (confirm("是否确定退回该数据？")) {
            $.ajax({
                type: 'POST',
                url: rootPath + '/AllowanceIssueCheck/ReturnToIssue',
                data: { fallowanceIssueEntryID: allowanceIssueEntryID, FIssueID: $("#hidFIssueID").val(), type: type, EditType: "ts" },
                success: function (result) {
                    var sdata = result.split("||");
                    if (sdata[0] == "ok") {
                        $("tr[id='" + id + "']").remove();
                        $("#zjse").text(sdata[1]);
                        $("#zjFAllowanceAmount").text(sdata[2]);
                        $("#zjYBTJE").text(sdata[3]);
                        $("#zjBTJE").text(sdata[4]);
                    }
                    else if (sdata[0] == "ex") {
                        alert("系统异常");
                    }
                    else {
                        alert(sdata[0]);
                    }
                }
            });
        }
    }


    function Open(allowanceIssueEntryID, id) {
        var type = $("#hidtype").val();
        $.ajax({
            type: 'POST',
            url: rootPath + '/AllowanceIssueCheck/OpenToIssue',
            data: { fallowanceIssueEntryID: allowanceIssueEntryID, FIssueID: $("#hidFIssueID").val(), type: type, EditType: "js" },
            success: function (result) {
                var sdata = result.split("||");
                if (sdata[0] == "ok") {
                    if (type == "1") {
                        $("tr[id='" + id + "']").remove();
                    }
                    else {
                        $('#' + allowanceIssueEntryID + 'open').hide();
                    }
                    $("#zjse").text(sdata[1]);
                    $("#zjFAllowanceAmount").text(sdata[2]);
                    $("#zjYBTJE").text(sdata[3]);
                    $("#zjBTJE").text(sdata[4]);
                }
                else {
                    alert("系统异常");
                }
            }
        });
    }

    function Return(allowanceIssueEntryID, id) {
        var type = $("#hidtype").val();
        if (confirm("是否确定退回该数据？")) {
            $.ajax({
                type: 'POST',
                url: rootPath + '/AllowanceIssueCheck/ReturnToIssue',
                data: { fallowanceIssueEntryID: allowanceIssueEntryID, FIssueID: $("#hidFIssueID").val(), type: type, EditType: "js" },
                success: function (result) {
                    var sdata = result.split("||");
                    if (sdata[0] == "ok") {
                        $("tr[id='" + id + "']").remove();
                        $("#zjse").text(sdata[1]);
                        $("#zjFAllowanceAmount").text(sdata[2]);
                        $("#zjYBTJE").text(sdata[3]);
                        $("#zjBTJE").text(sdata[4]);
                    }
                    else if (sdata[0] == "ex") {
                        alert("系统异常");
                    }
                    else {
                        alert(sdata[0]);
                    }
                }
            });
        }
    }

    function checkAdd(obj) {
        var value = $("#xz").html() ;
        var boc = document.getElementsByName("box");
        if (value == "全选") {
            for (var i = 0; i < boc.length; i++) {
                boc[i].checked = true;
            }
            $("#xz").html("取消");
        }
        else {
            for (var i = 0; i < boc.length; i++) {
                boc[i].checked = false;
            }
            $("#xz").html("全选");
        }
    }
   
</script>

   <style>
    .tableStyle
{
	width: 100%;
	border: solid 1px black;
		padding: 6px 5px;
	border-collapse: collapse;
}
.tableStyle td
{
}

.tableStyle .tdClass
{
	padding: 0px;
  padding: 6px 5px;
	border: solid 1px black;
}
.tableStyle th
{
	text-align: right;
	padding: 6px 5px;
	border: solid 1px black;
}
.tableStyle .button
{
	margin: 2px 0px 0px 2px;
	float: left;
}

text{border:1px solid #aecaf0;}

    </style>
</head>
<body>
    @using (Html.BeginForm("CheckSave", "AllowanceIssueCheck", FormMethod.Post, new { id = "form1" }))
    {
 @Html.DevExpress().Menu(settings =>
{
    settings.Name = "toolBarMenu";
    settings.ItemAutoWidth = false;
    settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
    settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
    settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

    settings.Items.Add(item =>
    {
        item.Name = "btnSubmitALL";
        item.Text = "发送选中全部";
        item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");
    });
    //if (ViewData["showOpen"] == "true")
    //{
    //    settings.Items.Add(item =>
    //    {
    //        item.Name = "btnSubmit";
    //        item.Text = "发送期号";
    //        item.Image.Url = Url.Content("~/Content/ControlImages/button_add.png");
    //    });
    //}
    //settings.Items.Add(item =>
    //{
    //    item.Name = "btnReturn";
    //    item.Text = "退回";
    //    item.Image.Url = Url.Content("~/Content/ControlImages/undo_blue.png");
    //});
    settings.Items.Add(item =>
    {
        item.Name = "btnback";
        item.Text = "返回";
        item.Image.Url = Url.Content("~/Content/ControlImages/back.png");
    });

    settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
    settings.ItemLinkMode = ItemLinkMode.ContentBounds;
}).GetHtml()
    <div>
    <table width="100%">
    <tr>
    <td align="center">
    <h1>企业扶持资金 @ViewData["FIssueNo"]</h1>
    </td>
    </tr>
    </table>
    <table class="tableStyle">
    <tr>
       <td class="tdClass" align="center"><a href="#" onclick="checkAdd(this)" id="xz" name="xz">全选</a></td>
    <td class="tdClass" align="center">操作</td>
    <td class="tdClass" align="center">纳税人编码</td>
    <td class="tdClass" align="center">纳税人名称</td>
    <td class="tdClass" align="center">税种</td>
    <td class="tdClass" align="center">实缴税金</td>
    <td class="tdClass" align="center">基数</td> 
    <td class="tdClass" align="center">基数内<br />补贴率</td>
    <td class="tdClass" align="center">基数外<br />补贴率<br />(补贴率)</td>
    <td class="tdClass" align="center">可补金额<br />(万元)</td>
    <td class="tdClass" align="center">已补金额<br />(万元)</td>
    <td class="tdClass" align="center">本期补贴<br />金额<br />(万元)</td>
    </tr>
   @if (ViewData["showdata"] != null)
   {

       foreach (System.Data.DataRow dr in (ViewData["showdata"] as System.Data.DataTable).Rows)
       {
           z++;
           <tr id="@z">
            @if (dr["cz"].ToString() == "合计")
            {
            <td class="tdClass" align="center"></td>
            }
            else
            {
                 <td class="tdClass" align="center"><input type="checkbox" value="@dr["FAllowanceIssueEntryID"]" id ='@dr["FAllowanceIssueEntryID"]' name='box' /></td>
            }
                
                 <td class="tdClass" align="center">
            @if (dr["cz"].ToString() == "合计")
            {
                @:@dr["cz"]
            }
            else
            {
                if (dr["FTaxClassAllowanceName"] != "特殊调整")
                {
                    if (dr["FStatus"].ToString() == "1")
                    {
                <a href="#" onclick="Open('@dr["FAllowanceIssueEntryID"]','@z')" id="@dr["FAllowanceIssueEntryID"]open">发送</a>
                <a href="#" onclick="Return('@dr["FAllowanceIssueEntryID"]','@z')">退回</a>
                    }
                    else
                    {
                        <a href="#" onclick="Return('@dr["FAllowanceIssueEntryID"]','@z')">退回</a>    
                    }
                }
                else
                {
                    if (dr["FStatus"].ToString() == "1")
                    {
                <a href="#" onclick="Opents('@dr["FAllowanceIssueEntryID"]','@z')" id="@dr["FAllowanceIssueEntryID"]open">发送</a>
                <a href="#" onclick="Returnts('@dr["FAllowanceIssueEntryID"]','@z')">退回</a>
                    }
                    else
                    {
                        <a href="#" onclick="Returnts('@dr["FAllowanceIssueEntryID"]','@z')">退回</a>    
                    }
                }

            }
                </td>
                 @if (dr["cz"].ToString() == "合计")
                 {
                 <td class="tdClass" align="center">@dr["NSRBM"]</td>
                <td class="tdClass" align="left">@dr["NSRMC"]</td>
                <td class="tdClass" align="center">@dr["FTaxClassAllowanceName"]</td>
                <td class="tdClass" align="right" id='zjse'> @dr["se"]</td>
                <td class="tdClass" align="right" >@dr["FBaseAmount"]</td>
                <td class="tdClass" align="right">@dr["FInnerRate"]</td>
                <td class="tdClass" align="right">@dr["FOuterRate"]</td>
                <td class="tdClass" align="right" id='zjFAllowanceAmount'>@dr["FAllowanceAmount"]</td>
                <td class="tdClass" align="right" id='zjYBTJE'>@dr["YBTJE"]</td>
                <td class="tdClass" align="right" id='zjBTJE'>@dr["BTJE"]</td>
                 }
                 else
                 {
                <td class="tdClass" align="center">@dr["NSRBM"]</td>
                <td class="tdClass" align="left">@dr["NSRMC"]</td>
                                            if (dr["FTaxClassAllowanceName"] != "特殊调整")
                                            {
                <td class="tdClass" align="center"><a href="#" onclick ="look('@dr["FTaxClassAllowanceNo"]','@dr["FTaxAuditId"]')"> @dr["FTaxClassAllowanceName"] </a></td>
                                            }
                                            else
                                            {
                   <td class="tdClass" align="center"> @dr["FTaxClassAllowanceName"] </td>
                                            }
                <td class="tdClass" align="right">@dr["se"]</td>
                <td class="tdClass" align="right">@dr["FBaseAmount"]</td>
                <td class="tdClass" align="right">@dr["FInnerRate"]</td>
                <td class="tdClass" align="right">@dr["FOuterRate"]</td>
                <td class="tdClass" align="right">@dr["FAllowanceAmount"]</td>
                <td class="tdClass" align="right">@dr["YBTJE"]</td>
                <td class="tdClass" align="right">@dr["BTJE"]</td>
           
                 }
           </tr>
       }
   }
    </table>

    @Html.Hidden("hidFIssueNo", ViewData["FIssueNo"])
    @Html.Hidden("hidSType", ViewData["SType"])
    @Html.Hidden("hidcheckNoALL", "")
    @Html.Hidden("hidtype", ViewData["type"])
    @Html.Hidden("hidFIssueID", ViewData["FIssueID"])
    @Html.Hidden("hdjsAlert", (ViewData["jsAlert"]))
    @Html.Hidden("hidFAllowanceClassNo", Model.FAllowanceClassNo)
    </div>
    }
</body>
</html>
